//
//  ShopCarTool.m
//  壳牌喜力促销积分商城
//
//  Created by LEO on 15/3/16.
//  Copyright (c) 2015年 xrd. All rights reserved.
//

#import "ShopCarTool.h"
#import "HttpRequestTool.h"
#import "DBOprationTool.h"
@interface ShopCarTool()


@end
@implementation ShopCarTool

-(NSMutableArray *)items{
    if (_items == nil) {
        _items = [[NSMutableArray alloc]init];
    }
    
    return _items;
}



+(NSArray *)shopCarArray{

      //从网络获取购物车数据
    NSArray *items = nil;
    
    
   
    //从plist文件获取数据 字典转模型
    items = [[NSArray alloc] init];
#warning 改了这里
    NSArray *array = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ShopCarItems" ofType:@"plist"]];
    
    NSMutableArray *arrayM = [NSMutableArray array];
    
    for (NSDictionary *dict in array) {
        [arrayM addObject:[GoodsModel goodsWithDict:dict]];
    }
    
    items = arrayM;
    NSLog(@"%@",items);
    return items;
    
}
//操作购物车
//CRUD
-(void)addToShopCarArray:(NSArray*)items{
    [_items addObjectsFromArray:items];
}


-(void)removeShopCarArray:(NSArray*)items{
    [_items removeObjectsInArray:items];
}

/*
-(void)removeAllShopCarArray{
    [_items removeAllObjects];
}
 */


//积分操作


@end
